Using aliases
Use an Alias to get consistent access to a Kanzi node. You can use aliases to access nodes both in Kanzi Studio and using the Kanzi Engine API or scripting. Because while creating your application in Kanzi Studio you move nodes in the scene graph of your project, the easiest way to keep track of them is to use aliases. You can retrieve the alias target nodes with the API or scripting using the name of the alias, regardless of the node location in the project.
Note that you must always add aliases to the resource dictionary of the node from which you want to retrieve them.
Creating an alias from a node
When you create an alias from a node, Kanzi Studio adds that alias resource dictionary of the nearest ancestor of that node that contains a resource dictionary. For example, if a Scene has a resource dictionary and it contains a Camera, when you create an alias directly from the Camera node, Kanzi Studio automatically adds the alias pointing to the Camera node to the resource dictionary of the Scene node.
To create an alias:
- In the Project press Alt and right-click the node to which you want Kanzi Studio to automatically add the alias from the descendants of that node, and select Resource Dictionary.
For example, if you want to use aliases to access the nodes inside the Scene node, add the Resource Dictionary to that Scene.
- In the Project press Alt and right-click a descendant node of the node that contains a resource dictionary, and select Alias.
For example, in a Scene that contains a Camera, press Alt and right-click the Camera, and select Alias.
Kanzi Studio creates an alias pointing to the node from which you created the alias and adds it to the resource dictionary of its nearest parent node that contains a resource dictionary.
Creating an alias and manually setting its target
To create an alias and manually set its target:
- If you do not have the Context Resources window open, select > Context Resources.
- In the Project press Alt and right-click the node to the resource dictionary of which you want to add an alias, and select Resource Dictionary.
For example, if you want to use aliases to access the nodes inside the Scene node, add the Resource Dictionary to that Scene.
- In the Context Resources click Add resource to add an alias to the resource dictionary of the node selected in the Project and select Create New > Alias.
- In the Properties set:
- Name to the name you want to use to access the target node.
- Target to the node you want to access with the alias.
Use <Relative> to enter a path that is relative to the node to the resource dictionary of which you added the alias.
Use absolute path when the target node is reachable from the node that owns the resource dictionary where the alias is.
Using aliases in bindings
Use bindings to update properties or property attributes of one node with the properties or property attributes of other nodes.
To use aliases in bindings, enter in curly braces the #
sign followed by the alias name, followed by a forward slash and property name of the alias' target.
For example, to bind a property to the Layout Width property of the target node of the alias named Sphere in the Expression of the Binding Argument Editor enter
{#Sphere/LayoutWidth}
See Using bindings and Reference for bindings expressions.
Using an alias to set a target for an action
To use an alias to define a target item for an action:
- Create an alias. See Creating an alias from a node.
- Add a trigger to a node. See Using triggers.
- In the Properties click the drop-down menu select an action.
For example, select Play Animation action.
- In the Message Editor set the Target Item property to the alias you created in the first step, and click Save.
Using Aliases in the API
To use aliases to access nodes using the API
// Get the reference to the Grid List Box 3D node using the alias #Grid List Box that is
// in the resource dictionary of the Scene node.
GridListBox3DSharedPtr gridListBox = scene->lookupNode<GridListBox3D>("#Grid List Box");
See also
Using local and global resources
Resource management
Using bindings
Reference for bindings expressions
Open topic with navigation